package com.example.pojo;


import com.baomidou.mybatisplus.annotation.*;
import com.example.Service.AttendanceService;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.annotation.Resource;
import java.time.LocalDate;
import java.time.LocalTime;
import java.util.Map;

@Data
@AllArgsConstructor
@NoArgsConstructor
@TableName("clocking_in")

public class Attendance{ //考勤表
    //考勤id
    @TableId(value = "id",type = IdType.AUTO)
    private Integer id;

    //工号id
    private Integer userid;

    // 早上时间
    @TableField(fill = FieldFill.INSERT)
    @JsonFormat(pattern = "HH:mm:ss")
    private LocalTime earlyTime;

    // 晚上时间
    @TableField(fill = FieldFill.INSERT)
    @JsonFormat(pattern = "HH:mm:ss")
    private LocalTime lateTime;

    // 当天日期
    @TableField(fill = FieldFill.INSERT)
    @JsonFormat(pattern = "yyyy-MM-dd")
    private LocalDate dayTime;

    //打卡状态
    private Integer status;

    //打卡次数
    private Integer times;

//    //打卡次数
//    private Integer year;
//    //打卡次数
//    private Integer month;

    //考勤规定时间
    private String remark;

    // 新增数据库不存在的用户名属性
    @TableField(exist = false)
    private String username;
    // 罚款信息
    @TableField(exist = false)
    private String importContent;
    // 罚款数额
//    @TableField(exist = false)
    private Double salaryDeduction;
    // 罚款数额文本
    @TableField(exist = false)
    private String salaryDeductionString;

    @TableField(exist = false)
    @Resource
    private AttendanceService attendanceService;
    public void setImportContent(Integer status) {
        String content = "";
        double count = 0;
        switch (status){
            case 0:
                //正常
                content = "正常";
                break;
            case 1:
                //迟到
                content = "迟到";
                count = 50.0;
                break;
            case 2:
                //早退
                content = "早退";
                count = 50.0;
                break;
            case 3:
                //早退,迟到
                content = "早退,迟到";
                count = 100.0;
                break;
            case 4:
                //缺卡
                content = "缺卡";
                count = 150;
                break;
            case 5:
                //旷工
                content = "旷工";
                count = 200;
                break;
        }
        this.salaryDeduction =count;
        this.importContent = content;
    }

}
